package puzzle.game.project;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

public class Puzzle extends Activity implements OnClickListener {

	private TextView mainText = null;
	private static final int OPTION_SELECTED = 0;
	
	public int difficult = 0;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
		View startButton = this.findViewById(R.id.Start_button);
		startButton.setOnClickListener(this);
		
		View optionButton = this.findViewById(R.id.Option_button);
		optionButton.setOnClickListener(this);
		
		View multiButton = this.findViewById(R.id.Multi_button);
		multiButton.setOnClickListener(this);
    }
    
	public void onClick(View v){
		//ABOUT BUTTON Activity
		
		switch (v.getId()){
		case R.id.Start_button:
			if(difficult != 0) {
				Intent startIntent = new Intent(this, GetPicture.class);
				startIntent.putExtra("DIFFICULT", difficult);
				startActivity(startIntent);
			}
			break;
			
		case R.id.Option_button:
			Intent optionIntent = new Intent(this, GetOption.class);
			startActivityForResult(optionIntent, OPTION_SELECTED);
			break;
			
		case R.id.Multi_button:
			//to-do. call Multi Play Activity 
//			Intent multiIntent = new Intent(this, Data.class);
//			startActivityForResult(j, ACTIVITY_SELECTED);
//			break;
		}
	}
	
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
		super.onActivityResult(requestCode, resultCode, intent);

		mainText = (TextView)findViewById(R.id.main_text);

		Bundle extras = intent.getExtras();
		
		switch(requestCode) {
		case OPTION_SELECTED:
			difficult = extras.getInt("selectedOption");
			String strDifficult;
				if (difficult == 3)
					strDifficult = "Easy";
				else if (difficult == 4)
					strDifficult = "Medium";
				else 
					strDifficult = "Hard";			
			mainText.setText(strDifficult);
			break;
		}
	}
}